package com.ruoyi.web.controller.basic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.mapper.BasicSiteTypeMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BasicSiteType;
import com.ruoyi.system.service.IBasicSiteTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站点类型;Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/basicSiteType")
public class BasicSiteTypeController extends BaseController
{
    @Autowired
    private IBasicSiteTypeService basicSiteTypeService;

    @Autowired
    private BasicSiteTypeMapper basicSiteTypeMapper;

    /**
     * 获取站点类型;下拉框数据
     * @return
     */
    @GetMapping("/getSiteTypeDictList")
    public AjaxResult getSiteTypeDictList() {
        BasicSiteType basicSiteType = new BasicSiteType();
        basicSiteType.setSiteTypeStatus("启用");
        List<BasicSiteType> siteTypeList = basicSiteTypeMapper.selectBasicSiteTypeList(basicSiteType);
        return AjaxResult.success(siteTypeList);
    }
    /**
     * 查询站点类型;列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicSiteType:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicSiteType basicSiteType)
    {
        startPage();
        List<BasicSiteType> list = basicSiteTypeService.selectBasicSiteTypeList(basicSiteType);
        return getDataTable(list);
    }

    /**
     * 导出站点类型;列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicSiteType:export')")
    @Log(title = "站点类型;", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicSiteType basicSiteType)
    {
        List<BasicSiteType> list = basicSiteTypeService.selectBasicSiteTypeList(basicSiteType);
        ExcelUtil<BasicSiteType> util = new ExcelUtil<BasicSiteType>(BasicSiteType.class);
        util.exportExcel(response, list, "站点类型;数据");
    }

    /**
     * 获取站点类型;详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicSiteType:query')")
    @GetMapping(value = "/{siteTypeId}")
    public AjaxResult getInfo(@PathVariable("siteTypeId") Long siteTypeId)
    {
        return success(basicSiteTypeService.selectBasicSiteTypeBySiteTypeId(siteTypeId));
    }

    /**
     * 新增站点类型;
     */
    @PreAuthorize("@ss.hasPermi('system:basicSiteType:add')")
    @Log(title = "站点类型;", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicSiteType basicSiteType)
    {
        return toAjax(basicSiteTypeService.insertBasicSiteType(basicSiteType));
    }

    /**
     * 修改站点类型;
     */
    @PreAuthorize("@ss.hasPermi('system:basicSiteType:edit')")
    @Log(title = "站点类型;", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicSiteType basicSiteType)
    {
        return toAjax(basicSiteTypeService.updateBasicSiteType(basicSiteType));
    }

    /**
     * 删除站点类型;
     */
    @PreAuthorize("@ss.hasPermi('system:basicSiteType:remove')")
    @Log(title = "站点类型;", businessType = BusinessType.DELETE)
	@DeleteMapping("/{siteTypeIds}")
    public AjaxResult remove(@PathVariable Long[] siteTypeIds)
    {
        return toAjax(basicSiteTypeService.deleteBasicSiteTypeBySiteTypeIds(siteTypeIds));
    }
}
